package com.nakamachizu.meta.session;

//@javax.annotation.Generated(value = { "slim3-gen", "EA1-SNAPSHOT" }, date = "2010-03-09 17:58:36")
/** */
public final class MapDataSessionMeta extends org.slim3.datastore.ModelMeta<com.nakamachizu.model.session.MapDataSession> {

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<com.nakamachizu.model.session.MapDataSession, com.google.appengine.api.datastore.Key> key = new org.slim3.datastore.CoreAttributeMeta<com.nakamachizu.model.session.MapDataSession, com.google.appengine.api.datastore.Key>(this, "__key__", "key", com.google.appengine.api.datastore.Key.class);

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<com.nakamachizu.model.session.MapDataSession, com.google.appengine.api.datastore.Key> mapKey = new org.slim3.datastore.CoreAttributeMeta<com.nakamachizu.model.session.MapDataSession, com.google.appengine.api.datastore.Key>(this, "mapKey", "mapKey", com.google.appengine.api.datastore.Key.class);

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<com.nakamachizu.model.session.MapDataSession, java.lang.Integer> schemaVersion = new org.slim3.datastore.CoreAttributeMeta<com.nakamachizu.model.session.MapDataSession, java.lang.Integer>(this, "schemaVersion", "schemaVersion", java.lang.Integer.class);

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<com.nakamachizu.model.session.MapDataSession, java.lang.Long> version = new org.slim3.datastore.CoreAttributeMeta<com.nakamachizu.model.session.MapDataSession, java.lang.Long>(this, "version", "version", java.lang.Long.class);

    /** */
    public final org.slim3.datastore.StringAttributeMeta<com.nakamachizu.model.session.MapDataSession> viewPassword = new org.slim3.datastore.StringAttributeMeta<com.nakamachizu.model.session.MapDataSession>(this, "viewPassword", "viewPassword");

    private static final MapDataSessionMeta singleton = new MapDataSessionMeta();

    /**
     * @return the singleton
     */
    public static MapDataSessionMeta get() {
       return singleton;
    }

    /** */
    public MapDataSessionMeta() {
        super("MapDataSession", com.nakamachizu.model.session.MapDataSession.class);
    }

    @Override
    public com.nakamachizu.model.session.MapDataSession entityToModel(com.google.appengine.api.datastore.Entity entity) {
        com.nakamachizu.model.session.MapDataSession model = new com.nakamachizu.model.session.MapDataSession();
        model.setKey(entity.getKey());
        model.setMapKey((com.google.appengine.api.datastore.Key) entity.getProperty("mapKey"));
        model.setSchemaVersion(longToInteger((java.lang.Long) entity.getProperty("schemaVersion")));
        model.setVersion((java.lang.Long) entity.getProperty("version"));
        model.setViewPassword((java.lang.String) entity.getProperty("viewPassword"));
        return model;
    }

    @Override
    public com.google.appengine.api.datastore.Entity modelToEntity(java.lang.Object model) {
        com.nakamachizu.model.session.MapDataSession m = (com.nakamachizu.model.session.MapDataSession) model;
        com.google.appengine.api.datastore.Entity entity = null;
        if (m.getKey() != null) {
            entity = new com.google.appengine.api.datastore.Entity(m.getKey());
        } else {
            entity = new com.google.appengine.api.datastore.Entity(kind);
        }
        entity.setProperty("mapKey", m.getMapKey());
        entity.setProperty("schemaVersion", m.getSchemaVersion());
        entity.setProperty("version", m.getVersion());
        entity.setProperty("viewPassword", m.getViewPassword());
        return entity;
    }

    @Override
    protected com.google.appengine.api.datastore.Key getKey(Object model) {
        com.nakamachizu.model.session.MapDataSession m = (com.nakamachizu.model.session.MapDataSession) model;
        return m.getKey();
    }

    @Override
    protected void setKey(Object model, com.google.appengine.api.datastore.Key key) {
        validateKey(key);
        com.nakamachizu.model.session.MapDataSession m = (com.nakamachizu.model.session.MapDataSession) model;
        m.setKey(key);
    }

    @Override
    protected long getVersion(Object model) {
        com.nakamachizu.model.session.MapDataSession m = (com.nakamachizu.model.session.MapDataSession) model;
        return m.getVersion() != null ? m.getVersion().longValue() : 0L;
    }

    @Override
    protected void incrementVersion(Object model) {
        com.nakamachizu.model.session.MapDataSession m = (com.nakamachizu.model.session.MapDataSession) model;
        long version = m.getVersion() != null ? m.getVersion().longValue() : 0L;
        m.setVersion(Long.valueOf(version + 1L));
    }

}